package edu.nf.hotel.roominfo.impl;

import edu.nf.hotel.roominfo.RoomInfo;
import edu.nf.hotel.roominfo.RoomInfoService;
import edu.nf.hotel.roominfo.all.RoomTypeInfo;
import edu.nf.hotel.roominfodao.RoomTypeInfoDao;
import edu.nf.hotel.roominfodao.impl.RoomTypeInfoImpl;
import edu.nf.hotel.util.PageUtils;
import edu.nf.hotel.vo.PageVO;

import java.util.List;

/**
 * @Date 2023-07-03
 * @Author 陈
 */
public class RoomInfoServiceImpl implements RoomInfoService {
    @Override
    public PageVO<List<RoomTypeInfo>> listRoom(RoomInfo roomName, int page, int limit) {
        //先根据page计算出从列表的第几条开始查询
        int numberOf = PageUtils.toNumberOf(page, limit);

        RoomTypeInfoDao dao= new RoomTypeInfoImpl();

        List<RoomTypeInfo> list = dao.listInformation(roomName,numberOf,limit);

        Long count = dao.count();
        //将数据封装成PageVo对象
        return PageUtils.toPageVO(list,count);
    }
}
